package com.iteaj.demo.server.handle;

import com.iteaj.demo.server.ServerProtocolType;
import com.iteaj.demo.server.protocol.ClientRequestPlatformDemoProtocol;
import com.iteaj.demo.server.protocol.PlatformRequestClientDemoProtocol;
import com.iteaj.network.server.service.DeviceRequestHandle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 客户端请求协议默认处理器
 */
@Component
public class ClientRequestPlatformDemoHandle implements DeviceRequestHandle<ClientRequestPlatformDemoProtocol> {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public Object business(ClientRequestPlatformDemoProtocol protocol) {
        logger.info("协议处理器 客户端请求处理 - 设备编号: {}", protocol.getEquipCode());

        protocol.setRespContent(ServerProtocolType.ClientRequest.getCode());

        new PlatformRequestClientDemoProtocol(protocol.getEquipCode(), ServerProtocolType.PlatformRequest.getCode()).request();
        return null;
    }
}
